﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Wicresoft.Common;
using JDEduTrain.Framework.Entity;
using JDEduTrain.Framework.Business;
using Wicresoft.Framework.Organization;
using NameControlLib;

public partial class Page_DeptTrainDetailStatDetail : BaseAuthenticationPage
{
    public string DeptName
    {
        get
        {
            if (Request["DeptName"] != null)
                return Request["DeptName"];
            return string.Empty;
        }
    }
    public bool IsViewPass
    {
        get
        {
            if (Request["IsViewPass"] != null)
                return bool.Parse(Request["IsViewPass"]);
            return false;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        this.UseTabber = true;
        if (!IsPostBack)
        {
            BindClassMember();

          
        }
    }

    protected DataTable DTUserPageList
    {
        get
        {
            if (ViewState["DTUserPageList"] != null)
            {
                return (DataTable)ViewState["DTUserPageList"];
            }
            return new DataTable();
        }
        set
        {
            ViewState["DTUserPageList"] = value;
        }
    }


    protected void BindClassMember()
    {
        int recordCount = 0;
        DataTable dtMember = BLTrain.GetUserList(dpPager.CurrentPageIndex, dpPager.PageSize, string.Format("{0} = '{1}'", UserExtend.SQLCOL_THIRDLEVELDEPTDISPLAYNAME, HttpUtility.UrlDecode(DeptName)), UserExtend.SQLCOL_THIRDLEVELDEPTDISPLAYNAME, ref recordCount);
        dtMember.Columns.Add("YearScore",typeof(float));
        dtMember.Columns.Add("TotalScore",typeof(float));
        foreach (DataRow dr in dtMember.Rows)
        {
            dr["YearScore"] = BLTrain.GetYearScoreByMemberID(new Guid(dr["ID"].ToString()));
            dr["TotalScore"] = BLTrain.GetAllScoreByMemberID(new Guid(dr["ID"].ToString()));
        }
        dpPager.RecordCount = recordCount;
        DataView dv = dtMember.DefaultView;
        if (IsViewPass)
        {
            float finishScore = 0;
            float.TryParse(ConfigurationManager.AppSettings["TurnsTotalScore"], out finishScore);
            dv.RowFilter = "TotalScore >" + finishScore;
            dpPager.RecordCount = dv.Count;
        }
        rptOrderInfo.DataSource = dv;
        rptOrderInfo.DataBind();

    }
    protected void dpPager_PreRender(object sender, EventArgs e)
    {
        BindClassMember();
    }
    protected void rptOrderInfo_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        //{
        //    Label lFullName = e.Item.FindControl("lFullName") as Label;

        //    string id = DTUserPageList.Rows[e.Item.ItemIndex]["ID"].ToString();
        //    NameControlLib.NameInfo userControl = new NameInfo();
        //    userControl.ID = "UserNameControl_" + id;
        //    userControl.UserID = new Guid(id);
        //    userControl.ScriptPath = "../Js/NameInfo.js";
        //    lFullName.Controls.Add(userControl);
        //    if (string.IsNullOrEmpty(lFullName.Text))
        //    {

        //    }

        //}
    }
}
